package com.itbaizhan.shopping_manager_api.security;

import com.itbaizhan.shopping_common.result.BaseResult;
import org.apache.dubbo.common.json.JSON;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author spf
 * @date 2023/12/16
 * @time 12:16
 */

// 退出成功处理器
public class MyLogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        httpServletResponse.setContentType("text/json;charset=utf-8");
        BaseResult result = new BaseResult(200, "注销成功", null);
        httpServletResponse.getWriter().write(JSON.json(result));
    }
}
